package dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class Login {
    public static boolean userLogin(String id,String pwd){
        String sql="select password from account where id =?";
        try {
            Connection conn=DataBaseConnect.getConnection();
            PreparedStatement pstmt=conn.prepareStatement(sql);
            pstmt.setString(1,id);
            ResultSet rs=pstmt.executeQuery();
            while (rs.next()){
                return pwd.equals(rs.getString(1));
            }
        }catch (Exception e){
            System.out.println("用户登录数据库连接error");
            e.printStackTrace();
        }
        return false;
    }
}
